/*
 * #%L
 * SwiftUIDataAccessLayer
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
package com.linkwithweb.products.swiftui.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.linkwithweb.products.swiftui.dataobject.BaseDataObject;

/**
 * Has all Common Column that are mapped
 * 
 * @author ashwin kumar
 * 
 */
public abstract class AbstractRowMapper implements RowMapper {

	/**
	 * @param baseDataObject
	 * @param rs
	 * @return
	 * @throws SQLException
	 */
	protected BaseDataObject mapDefaultColumns(BaseDataObject baseDataObject, ResultSet rs) throws SQLException {
		try {
			baseDataObject.setActive(rs.getBoolean("IS_ACTIVE"));
		} catch (Exception e) {
		}
		try {
			baseDataObject.setIdentifier(rs.getString("IDENTIFIER"));
		} catch (Exception e) {
		}
		try {
			baseDataObject.setIdentifierRole(rs.getString("IDENTIFIER_ROLE"));
		} catch (Exception e) {
		}
		try {
			baseDataObject.setCreatedBy(rs.getLong("CREATED_BY"));
		} catch (Exception e) {
		}
		try {
			baseDataObject.setCreatedDate(rs.getDate("CREATED_DATE"));
		} catch (Exception e) {
		}
		try {
			baseDataObject.setModifiedBy(rs.getLong("MODIFIED_BY"));
		} catch (Exception e) {
		}
		try {
			baseDataObject.setModifiedDate(rs.getDate("MODIFIED_DATE"));
		} catch (Exception e) {
		}
		return baseDataObject;
	}

}
